package com.qk;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.TimeUnit;

@SpringBootTest
public class RedisDemo {
    @Autowired
    private RedisTemplate redisTemplate;

    @Test
    public void testRedis(){
//        redisTemplate.opsForValue().set("name","qk");
//        System.out.println(redisTemplate.opsForValue().get("name"));
//
//        redisTemplate.opsForValue().set("age",18,10, TimeUnit.SECONDS);
//        System.out.println(redisTemplate.opsForValue().get("age"));


//        redisTemplate.opsForList().leftPushAll("list","a","b","c");
        System.out.println(redisTemplate.opsForList().range("list", 0, -1));

        redisTemplate.opsForList().leftPop("list");
        System.out.println(redisTemplate.opsForList().range("list", 0, -1));
    }
}
